home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998…tember: Reference Library / Dev.CD Sep 98 RL1.toast / Technical Documentation / develop / Additional Articles / Developing Symbiotic Apps / Symbiotic Samples / Symbiotic client source / Trident.cw10_pp / CTridentView.cp < prev    next >
Encoding:
Text File  |  1996-10-09  |  2.6 KB  |  114 lines  |  [TEXT/CWIE]

  1. // ===========================================================================
  2. //    CTridentView.cp                        ©1993 Metrowerks Inc. All rights reserved.
  3. // ===========================================================================
  4. //
  5.  
  6. #include "CTridentView.h"
  7. #include "CTridentApp.h"
  8. #include "CTridentCmds.h"
  9. #include "CTridentIdler.h"
  10. #include "TridentAESuite.h"
  11. #include <LStream.h>
  12.  
  13. #ifndef __TOOLUTILS__
  14. #include <ToolUtils.h>
  15. #endif
  16.  
  17. //==============================view stuff====================================
  18.  
  19. CTridentView*
  20. CTridentView::CreateTridentViewStream(
  21.     LStream    *inStream)
  22. {
  23.     return (new CTridentView(inStream));
  24. }
  25.  
  26. CTridentView::~CTridentView()
  27. {
  28.     if (fHeartBeatMonitor)
  29.         fHeartBeatMonitor->StopIdling();
  30.     delete fHeartBeatMonitor;
  31.  
  32. }
  33.  
  34.  
  35. CTridentView::CTridentView(
  36.     LStream    *inStream)
  37.             : LListBox(inStream)
  38. {
  39.     CHeartBeatIdler    *HeartBeatMonitor = new CHeartBeatIdler();
  40. //    CHeartBeatIdler    *HeartBeatMonitor = new CHeartBeatIdler(TRUE);
  41.     ThrowIfNULL_(HeartBeatMonitor);
  42.     fHeartBeatMonitor = HeartBeatMonitor;    //not idling until connected!
  43.     fHeartBeatMonitor->SetOwnerView(this);
  44.     fLegacyCompatable = FALSE;
  45.     this->ResetTicks();
  46. }
  47.  
  48. /*Boolean
  49. CTridentView::DoSomethingWillYa(
  50.     CommandT    inCommand ,
  51.     void         *ioParam )
  52.     {
  53.     return FALSE;  //not handled
  54.     }
  55. */
  56.  
  57. void
  58. CTridentView::ResetTicks( )
  59.     {
  60.     if (fHeartBeatMonitor)
  61.         fHeartBeatMonitor->ResetTicks();
  62.     }
  63.  
  64. void
  65. CTridentView::SendHeartBeat()
  66.     {
  67.     AppleEvent    heartappleEvent;
  68.     long clientSessionID = (long) ((CTridentWindow*) mSuperView)->fPortRefNum;
  69.     AEAddressDesc& theAddress = ((CTridentWindow*) mSuperView)->fAEAddressDesc;
  70.     OSErr err = AECreateAppleEvent(kAEAUXSuite, kAEHeartBeat, &theAddress, kAutoGenerateReturnID, kAnyTransactionID, &heartappleEvent);
  71.     err = ::AEPutParamPtr(&heartappleEvent, 'ssID',typeLongInteger,(Ptr)&clientSessionID,sizeof(long));            
  72.     UAppleEventsMgr::SendAppleEvent(heartappleEvent, TRUE);
  73.     this->ResetTicks();
  74.     }
  75.  
  76.  
  77. void
  78. CTridentView::HandleAppleEvent(
  79.     const AppleEvent     &inAppleEvent ,
  80.     AppleEvent             &outAEReply ,
  81.     AEDesc                 &outResult ,
  82.     long                inAENumber)
  83. {
  84.     switch (inAENumber) {
  85.     
  86.         case 407:
  87.             if (fHeartBeatMonitor)
  88.                 this->ResetTicks();
  89.                 
  90.             if (fLegacyCompatable)
  91.                 this->SendHeartBeat();  //basically use the server's time keeping
  92.             //yeah this could be cleaner but to make it simple as an example AND backwards
  93.             //compatable with the Appletalk Services Demo #1 host daemon, this is what you get. 
  94.  
  95.             break;
  96.     }
  97. }
  98. void
  99. CTridentView::FindCommandStatus(
  100.     CommandT    inCommand,
  101.     Boolean        &outEnabled,
  102.     Boolean        &outUsesMark,
  103.     Char16        &outMark,
  104.     Str255        outName)
  105. {
  106.  
  107. //handled by subclass!
  108. }
  109.  
  110. void CTridentView::SendInterval(long seconds) 
  111. {
  112. // handled by subclass
  113. }
  114.